package cn.bincker.web.blog.base.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.URL;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;

import static cn.bincker.web.blog.base.constant.RegexpConstant.STATION_URL_VALUE;

/**
 * 友情链接
 */
@Getter
@Setter
@Entity
public class FriendLink extends BaseEntity{
    @URL
    @NotEmpty
    @Column(nullable = false)
    private String favicon;

    @NotEmpty
    @Column(nullable = false)
    private String title;

    @URL
    @NotEmpty
    @Pattern(regexp = STATION_URL_VALUE, message = "不支持的域名")
    @Column(nullable = false)
    private String url;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private Status status;

    public enum Status {
        PENDING("审核中"),
        FORBIDDEN("禁用"),
        NORMAL("正常")
        ;
        @Getter
        private final String title;

        Status(String title) {
            this.title = title;
        }
    }
}
